import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const login = () => import('../views/Login.vue')
const layout = () => import('../views/Layout.vue')
const home = () => import('../views/Home.vue')
const menu = () => import('../views/Menu/index.vue')
const role = () => import('../views/Role/index.vue')
const admin = () => import('../views/Admin/index.vue')
const banner = () => import('../views/Banner/index.vue')
const category = () => import('../views/Category/index.vue')
const goods = () => import('../views/Goods/index.vue')
const member = () => import('../views/Member/index.vue')
const seckill = () => import('../views/Seckill/index.vue')
const speces = () => import('../views/Speces/index.vue')
const routes = [
  {
    path: '/login',
    component: login,
    meta: {
      title: '登录'
    }
  },
  {
    path: '/',
    component: layout,
    children: [
      {
        path: '/menu',
        component: menu,
        meta: {
          title: '菜单'
        },
      },
      {
        path: '',
        component: home,
        meta: {
          title: '主页'
        },
      },
      {
        path: '/role',
        component: role,
        meta: {
          title: '角色'
        },
      },
      {
        path: '/admin',
        component: admin,
        meta: {
          title: '管理员'
        },
      },
      {
        path:'/banner',
        component: banner,
        meta: {
          title: '轮播图管理'
        },
      },
      {
        path:'/category',
        component: category,
        meta: {
          title: '商品分类'
        },
      },
      {
        path:'/goods',
        component: goods,
        meta: {
          title: '商品管理'
        },
      },
      {
        path:'/member',
        component: member,
        meta: {
          title: '会员管理'
        },
      },
      {
        path:'/seckill',
        component: seckill,
        meta: {
          title: '秒杀活动'
        },
      },
      {
        path:'/speces',
        component: speces,
        meta: {
          title: '商品规格'
        },
      },
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  // base: process.env.BASE_URL,
  routes
})
router.beforeEach((to, from, next) => {
  document.title = to.meta.title
  next()
})
export default router
